package org.ricks.conditon.test;

import org.ricks.conditon.TaskCondition;

import java.util.function.Consumer;

// 具体条件实现
public class TotalRechargeCondition extends TaskCondition<RechargeEvent> {
    public TotalRechargeCondition(int targetAmount, Consumer<TaskCondition<RechargeEvent>> callback) {
        super(targetAmount, callback, RechargeEvent.class);
    }

    @Override
    protected void handleEvent(RechargeEvent event) {
        if (event.isValidPayment()) {
            currentValue += event.getAmount();
        }
    }
}
